import Redis from 'ioredis';
import config from '../../config';

export class RedisService {
  private client: Redis;

  constructor() {
    this.client = new Redis(config.redis);
  }

  async get(key: string): Promise<string | null> {
    return await this.client.get(key);
  }

  async setex(key: string, seconds: number, value: string): Promise<'OK'> {
    return await this.client.setex(key, seconds, value);
  }

  async del(key: string): Promise<number> {
    return await this.client.del(key);
  }
}